Most high-level programming languages, such as C and C++, provide a construct, called an array, which consists of a fixed number of memory locations of a single data type, for example, integers. Each memory location, or element of the array, is accessed by a numerical index representing the element's relative position in the array. However, in the Java® programming language an array is an object, and the array elements each point to a separate object that contains the element data, rather than pointing to the element data directly. As a consequence of the Java® language architecture, arrays have limitations, particularly in inefficient storage usage and performance overhead, not inherent in other programming languages. Current attempts to improve the Java® array implementation include adding a wrapper class that references the Java® array. While this allows customizable behavior, such as user-defined methods, the inefficient storage usage and performance issues remain. In another alternative, a custom application program interface (API) may be written to manipulate a raw byte buffer, thus simulating an array of data elements. However, memory usage and performance issues persist, since the objects created in this way are not entitled for the garbage collection process provided by the programming language.
As previously stated, working within the present Java® language to implement more robust array management features may have, as a consequence, performance implications. As such, it may be advantageous, among other things, to implement an enhanced Java® array as a Java® class, thus allowing the enhanced Java® array the behavior and features inherent in the Java® class generally, and thus enabling greater flexibility when working with memory structures while maintaining an encapsulated design.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates.